<template>
  <div class="wrapper">
    <div class="container m-member-wrapper">
      <!-- 个人信息 快速入口 -->
      <div class="m-member-index">
        <div class="mem-hd">
          <div class="svgIcon">
            <img src="../assets/img/userbj.png" alt style="width: 54px;" />
          </div>
          <div
            style="color:#fff;top: 80px;position: absolute;text-align: center;margin-left: -17px;width: 100%;text-align: center;"
          >{{userName}}</div>
          <div id="J-logIn" class="logIn" v-if="phone">
            <p class="company">
              <em></em>
            </p>
            <div class="scoreWrap">
              <span class="btn-logOut" @click="logout">退出</span>
            </div>
          </div>
          <div id="J-logOut" class="logOut" v-else>
            <router-link to="/login" class="btn">登录</router-link>
            <router-link to="/register" class="btn btn-register">注册</router-link>
          </div>
        </div>
        <div class="mem-extra flex">
          <a href="https://wpa.qq.com/msgrd?v=3&uin=578898066&site=qq&menu=yes" class="cell item">
            <svg-icon icon-class="i-qq" class-name="i-qq" />在线客服
          </a>
          <div class="cell item">
            <svg-icon icon-class="dianhua" class-name="dianhua" />400-618-0107
          </div>
        </div>
        <div id="J-memNotice" class="mem-notice">
          <p class="title">商城动态</p>
          <div class="J-noticeCntWrap noticeCnt" style="display: block;">
            <ul class="J-noticeCnt">
              <li class="empty" v-if="bulletinList.length === 0">暂时没有动态哦~</li>
              <li class="box" v-for="(item,index) in bulletinList" :key="index">
                <router-link target="_blank" :to="`./bulletin/?id=${item.id}`">
                  <p class="animate">{{item.title}}</p>
                </router-link>
              </li>
            </ul>
            <a href="javascript:;" class="J-more more" style="display: none;">
              <svg-icon icon-class="i-qq" class-name="i-qq" />
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
import {bulletin} from '@/api/home';
export default {
  name: "Wrapper",
  data() {
    return {
      bulletinList:[]
    };
  },
  computed: {
    ...mapGetters(["phone", "userName"]),
  },
  created() {
    this.getBulletin();
  },
  methods: {
    ...mapActions({
      fetchLogout: "user/logout",
    }),
    logout() {
      this.fetchLogout().then(() => {
        this.$router.push("/login");
      });
    },
    async getBulletin(){
      const res = await bulletin();
      this.bulletinList = res.data;
    }
  },
};
</script>

<style scoped lang="scss">
.container {
  width: 1200px;
  margin: 0 auto;
  z-index: 0;
}
.m-member-wrapper {
  position: relative;
  z-index: 3;
  .m-member-index {
    position: absolute;
    width: 280px;
    right: 0;
    top: 73px;
    border-radius: 3px;
    background: #fff;
    background: rgba(0, 0, 0, 0.6);
    .mem-hd {
      position: relative;
      height: 151px;
      padding: 0 17px;
      z-index: 0;
      .svgIcon {
        position: absolute;
        width: 72px;
        height: 72px;
        left: 50%;
        margin-left: -36px;
        top: -14px;
        text-align: center;
        border-radius: 100%;
        background: #4448f8;
      }
      .yonghu {
        width: 50px;
        height: 64px;
        line-height: 72px;
        color: #fff;
      }
      .logIn {
        position: absolute;
        width: 100%;
        left: 0;
        bottom: 12px;
        box-sizing: border-box;
        .company {
          height: 38px;
          line-height: 1.4em;
          padding: 0 34px;
          font-size: 14px;
          color: #fff;
          text-align: center;
          word-break: break-all;
          display: -webkit-box;
          display: -moz-box;
          display: -ms-flexbox;
          display: -webkit-flex;
          display: flex;
          -webkit-box-align: center;
          -moz-box-align: center;
          -ms-flex-align: center;
          -webkit-align-items: center;
          align-items: center;
          -webkit-box-pack: center;
          -moz-box-pack: center;
          -ms-flex-pack: center;
          -webkit-justify-content: center;
          justify-content: center;
        }
        .scoreWrap {
          margin-top: 12px;
          text-align: center;
          .score {
            position: relative;
            display: inline-block;
            height: 22px;
            line-height: 22px;
            padding: 0 10px 0 12px;
            color: #fed100;
            font-size: 12px;
            font-weight: bold;
            box-sizing: border-box;
            border-radius: 14px 0 0 14px;
            background: rgba(68, 72, 248, 0.4);
          }
          .btn-logOut {
            display: inline-block;
            height: 22px;
            line-height: 19px;
            box-sizing: border-box;
            border: 1px solid #ff0000;
            color: #ff0000;
            padding: 0 14px;
            border-radius: 3px;
            vertical-align: top;
            cursor: pointer;
          }
        }
      }
      .logOut {
        position: absolute;
        width: 100%;
        left: 0;
        bottom: 33px;
        text-align: center;
        .btn {
          display: inline-block;
          min-width: 85px;
          height: 28px;
          line-height: 26px;
          padding: 0 24px;
          margin: 0 10px;
          color: #fff;
          font-size: 14px;
          box-sizing: border-box;
          border-radius: 3px;
          border: 1px solid #4448f8;
          color: #ffffff;
        }
        .btn-register {
          color: #ff0000;
          border-color: #ff0000;
        }
      }
    }
    .mem-extra {
      width: 301px;
      height: 39px;
      margin-left: -11px;
      padding: 0 20px 0 5px;
      line-height: 39px;
      text-align: center;
      color: #fff;
      font-size: 14px;
      box-sizing: border-box;
      background: rgba(68, 72, 248, 0.7);
      .cell {
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        width: 0;
        -webkit-flex-basis: 0;
        -ms-flex-preferred-size: 0;
        flex-basis: 0;
        max-width: 100%;
        display: block;
        position: relative;
        color: #fff;
        .i-qq {
          padding-left: 1px;
        }
        .svg-icon {
          position: relative;
          display: inline-block;
          width: 24px;
          height: 24px;
          line-height: 22px;
          // border: 1px solid #fff;
          border-radius: 100%;
          margin-right: 4px;
          font-size: 14px;
          text-align: center;
          box-sizing: border-box;
          vertical-align: middle;
        }
      }
    }
    .mem-notice {
      min-height: 149px;
      box-sizing: border-box;
      padding: 8px 12px 30px;
      color: #fff;
      .title {
        margin: 6px 0 0;
        font-size: 14px;
        text-align: left;
      }
      .noticeCnt {
        display: none;
        height: 84px;
        overflow: hidden;
        -webkit-transition: 0.2s ease-in-out;
        -o-transition: 0.2s ease-in-out;
        transition: 0.2s ease-in-out;
        .J-noticeCnt {
          .empty {
            padding-top: 30px;
            text-align: center;
          }
        }
      }
    }
  }
}
.box {
  width: 200px;
  margin: 0 auto;
  position: relative;
  margin: 5px 0;
}
.animate {
  padding-left: 20px;
  font-size: 12px;
  padding: 3px 10px;
  color: #fff;
  white-space: nowrap;
  display: inline-block;
  cursor: pointer;
  animation: 15s wordsLoop linear infinite normal;
}

// @keyframes wordsLoop {
//   0% {
//     transform: translateX(0px);
//     -webkit-transform: translateX(0px);
//   }
//   100% {
//     transform: translateX(-100%);
//     -webkit-transform: translateX(-100%);
//   }
// }

// @-webkit-keyframes wordsLoop {
//   0% {
//     transform: translateX(0px);
//     -webkit-transform: translateX(0px);
//   }
//   100% {
//     transform: translateX(-100%);
//     -webkit-transform: translateX(-100%);
//   }
// }
</style>
